package info.wangyuan.agent.utils;

import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector;
import info.wangyuan.agent.common.annotation.Sensitive;


/**
 * 让 Jackson 识别 @Sensitive 注解
 */
public class SensitiveAnnotationIntrospector extends NopAnnotationIntrospector {
    @Override
    public Object findSerializer(Annotated a) {
        Sensitive ann = a.getAnnotation(Sensitive.class);
        if (ann != null && a.getRawType() == String.class) {
            return new SensitiveSerializer(ann.type());
        }
        return null;
    }
}
